#include <stdio.h>
//逆转数组的思路
void reverse(int* nums, int begin, int end)
{
    while(begin < end)
    {
        int tmp = nums[begin];
        nums[begin] = nums[end];
        nums[end] = tmp;

        ++begin;
        --end;
    }
}

// 三趟逆置倒的思路
void rotate(int* nums, int numsSize, int k){
    if(k > numsSize)
    {
        k %= numsSize;
    }
    
    reverse(nums, 0, numsSize-1);
    reverse(nums, 0, k-1);
    reverse(nums, k, numsSize-1);
}

void Print(int* num, int n)
{
    for (int i = 0; i < n; i++)
        printf("%d ", num[i]);
    printf("\n");

}

int main()
{
    int arr[] = {1, 2, 3, 4, 5, 6, 7};
    reverse(arr, 0, 6);
    Print(arr, sizeof(arr) / sizeof(int));

    return 0;
}